package com.cskaoyan.controller;


import com.cskaoyan.bean.BaseRespVo;
import com.cskaoyan.bean.bo.IssueCreateBO;
import com.cskaoyan.bean.param.BaseParam;

import com.cskaoyan.bean.po.IssuePO.IssueDataPO;
import com.cskaoyan.bean.vo.IssueVO.IssueCreateVO;
import com.cskaoyan.bean.vo.IssueVO.IssueData;
import com.cskaoyan.bean.vo.IssueVO.IssueUpdateVO;
import com.cskaoyan.service.IssueService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.text.SimpleDateFormat;
import java.util.Date;


@RestController
@RequestMapping("admin/issue")
public class IssueController {

    @Autowired
    IssueService issueService;

    @RequestMapping("list")
    //public BaseRespVo list(Integer page,Integer limit,String sort,String issue,String issuename) {
    public BaseRespVo list(BaseParam param,String question) {
        IssueData issueData = issueService.query(param,question);
        return BaseRespVo.ok(issueData);
    }
    @RequestMapping("create")
    //public BaseRespVo list(Integer page,Integer limit,String sort,String issue,String issuename) {
    public BaseRespVo create( @RequestBody IssueCreateBO issueCreateBO ) {
        int id = issueService.insertIssueGoods(issueCreateBO);



        IssueCreateVO issueCreateVO = new IssueCreateVO();
        issueCreateVO .setId(id);
        issueCreateVO.setQuestion(issueCreateBO.getQuestion());
        issueCreateVO.setAnswer(issueCreateBO.getAnswer());
        issueCreateVO.setAddTime(new Date());
        issueCreateVO.setUpdateTime( new Date());

        return BaseRespVo.ok(issueCreateVO);
    }
    @RequestMapping("update")
    //public BaseRespVo list(Integer page,Integer limit,String sort,String issue,String issuename) {
    public BaseRespVo update( @RequestBody IssueCreateBO issueCreateBO ) {
        int id = issueService.updateIssueGoods(issueCreateBO);

        IssueUpdateVO issueUpdateVO =issueService.selectIssueGoods(issueCreateBO);


        return BaseRespVo.ok(issueUpdateVO);
    }
    @RequestMapping("delete")
    //public BaseRespVo list(Integer page,Integer limit,String sort,String issue,String issuename) {
    public BaseRespVo delete(@RequestBody IssueCreateBO issueCreateBO) {
        issueService.update4delete (issueCreateBO);


        return BaseRespVo.ok(null);
    }
    /*
    @RequestMapping("ship")
    //public BaseRespVo list(Integer page,Integer limit,String sort,String issue,String issuename) {
    public BaseRespVo ship(@RequestBody ShipBO shipBO) {
       // System.out.println(shipChannel);
        issueService.updateShip(shipBO.getIssueId(),shipBO.getShipChannel(),shipBO.getShipSn());



        return BaseRespVo.ok(null);
    }
    @RequestMapping("refund")
    //public BaseRespVo list(Integer page,Integer limit,String sort,String issue,String issuename) {
    public BaseRespVo refund(@RequestBody RefundBO refundBO) {
        // System.out.println(shipChannel);
        issueService.updateRefund(refundBO.getIssueId(),refundBO.getRefundMoney());



        return BaseRespVo.ok(null);
    }*/
}
